﻿using System;
using UnityEngine;
using UnityEngine.UI;

// Token: 0x020002E2 RID: 738
public class EditSlider : MonoBehaviour
{
	// Token: 0x060012B4 RID: 4788 RVA: 0x000873DC File Offset: 0x000855DC
	public void Setup(string title, int id, float min, float max, float def, Action<int, float> action)
	{
		this.titleUI.text = title;
		this.id = id;
		this.sliderUI.minValue = min;
		this.sliderUI.maxValue = max;
		this.defVal = def;
		this.action = action;
		this.echo = true;
		this.sliderUI.value = def;
		this.inputUI.text = def.ToString("000");
		this.echo = false;
	}

	// Token: 0x060012B5 RID: 4789 RVA: 0x00087458 File Offset: 0x00085658
	public void SetValue(float val, bool invoke)
	{
		this.invoke = invoke;
		this.ChangeVal(val);
		this.invoke = true;
	}

	// Token: 0x060012B6 RID: 4790 RVA: 0x00087470 File Offset: 0x00085670
	public void ChangeText(string str)
	{
		float val = 0f;
		try
		{
			val = float.Parse(str);
		}
		catch
		{
			val = 0f;
		}
		this.ChangeVal(val);
	}

	// Token: 0x060012B7 RID: 4791 RVA: 0x000874B4 File Offset: 0x000856B4
	public void Default()
	{
		this.ChangeVal(this.defVal);
	}

	// Token: 0x060012B8 RID: 4792 RVA: 0x000874C4 File Offset: 0x000856C4
	public void ChangeVal(float val)
	{
		if (this.echo)
		{
			return;
		}
		this.echo = true;
		this.sliderUI.value = val;
		this.inputUI.text = val.ToString("000");
		if (this.action != null && this.invoke)
		{
			this.action(this.id, val);
		}
		this.echo = false;
	}

	// Token: 0x040017A6 RID: 6054
	public Text titleUI;

	// Token: 0x040017A7 RID: 6055
	public Slider sliderUI;

	// Token: 0x040017A8 RID: 6056
	public InputField inputUI;

	// Token: 0x040017A9 RID: 6057
	private float defVal = 0.5f;

	// Token: 0x040017AA RID: 6058
	private Action<int, float> action;

	// Token: 0x040017AB RID: 6059
	private int id;

	// Token: 0x040017AC RID: 6060
	private bool echo;

	// Token: 0x040017AD RID: 6061
	private bool invoke = true;
}
